import {
	mapGetters
} from 'vuex'
export default {
	computed: {
		...mapGetters('m_cart', ['total'])
	},
	watch: {
		// 监听购物车总数变化的情况，值发生变化，则修改徽标
		total(){
			this.setBadge()
		}
	},
	onShow() {
		this.setBadge()
	},
	methods: {
		setBadge() {
			uni.setTabBarBadge({
				index: 2,
				text: this.total + '' // text的值必须是字符串，而this.total是数值
			})
		}
	}
}